import unittest

import datetime
from meetingroom.models import Room
import os
from meetingroom.views import checkTimeConflict


def division_funtion(x, y):
    return x / y
class TestDivision(unittest.TestCase):

    def test_int(self):
        self.assertEqual(division_funtion(9, 3), 3)

    def test_int2(self):
        self.assertEqual(division_funtion(9, 4), 2.25)

    def test_float(self):
        self.assertEqual(division_funtion(4.2, 3), 1.4)

    def test_timeConflict(self):
        room=Room.objects.get(pk=14)
        date_time = datetime.datetime.strptime('2017-01-04', '%Y-%m-%d')
        self.assertEqual(checkTimeConflict(5,4,date_time,room,0),True,'期望True，结果False')         #c  d a  b
        self.assertEqual(checkTimeConflict(17,3,date_time,room,0),True,'期望True，结果False')         #a  b c  d
        self.assertEqual(checkTimeConflict(5, 5, date_time, room, 0), False, '期望False，结果True')  #c  a d  b
        self.assertEqual(checkTimeConflict(12,3,date_time,room,0),False,'期望False，结果True')       #a  c  d b
        self.assertEqual(checkTimeConflict(12,6,date_time,room,0),False,'期望False，结果True')       #a  c  b d

if __name__ == '__main__':
    unittest.main()
